package web;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.ui.ModelMap;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;

import beans.User;

import web.LoggedUser;

import dao.UserDAO;

public class AdminUserController extends MultiActionController{
  
	private UserDAO userDAO;

	private LoggedUser loggedUser;

	public void setLoggedUser(LoggedUser loggedUser) {
		this.loggedUser = loggedUser;
	}
	
	public void setUserDAO(UserDAO userDAO) {
		this.userDAO = userDAO;
	}
	
	
	public ModelAndView uzytkownicy(HttpServletRequest request,
			HttpServletResponse response) throws Exception {
		User user = loggedUser.getLoggedUser();
		ModelMap modelMap = new ModelMap();
		modelMap.addAttribute("user", user);
		modelMap.addAttribute("usersList", userDAO.GetAllUsers());
			return new ModelAndView("uzytkownicy", modelMap);
			
	}
	
}
